#include "TcpServerSession.h"
//#include "Common.h"

class FileTransferTcpServerSession : public TcpServerSession
{
public:
	FileTransferTcpServerSession(string local_addr,
								 uint16_t local_port);

	virtual void execute_srv_protocol(int* conn_sock);

private:
	int send_ctrl_msg(string send_msg, int* ptr_conn_sock);

	int recv_msg_type(int* ptr_conn_sock);
	int recv_msg_len(int* ptr_conn_sock);
	int recv_file_len(int* ptr_conn_sock, uint64_t& file_len);
	int recv_ctrl_msg(string* recv_msg, ssize_t msg_len, int* ptr_conn_sock);
	int recv_file(string file_name, int* ptr_conn_sock);

private:
	TcpFileTransferState m_transfer_state;
};
